package com.lry.basic.algorithm.common;

class PowerOfThree {
    public boolean isPowerOfThree(int n) {
        if(n<=0){
            return false;
        }
        if(n==1){
            return true;
        }
        long j = 1;

        while(j<n){
            j = j*3;
            if(j==n){
                return true;
            }
        }
        
        return false;
    }

    public boolean isPowerOfThree2(int n) {
        return n>0&&Math.pow(3,19)%n==0;
    }

    public static void main(String[] args) {
        System.out.println(new PowerOfThree().isPowerOfThree2(27));
    }
}